<?php
/**
 * wrapper class for permission table
 * @package naanal
 */
class ClsWPermission
{       
        /**
         * id
         * @package naanal
         * @var string 
         */
	protected $id=null;
        /**
         * feature id
         * @package naanal
         * @var string 
         */
        protected $feature_id=null;
        /**
         * permission
         * @package naanal
         * @var string 
         */
        protected $permission=null;
        /**
         * pdo
         * @package naanal
         * @var string 
         */
        private $pdo=null;  
        /**
         * tablename
         * @package naanal
         * @var string 
         */
	public $tableName=null;
        /**
         * construct
         * @package naanal
         */
	function __construct()
	{
		$this->rand=rand(1,99999);
		$this->tableName="permission";
		$this->pdo=ClsLPDO::getInstance();
	}
	  /**
           * get id
           * @package naanal
           * @return integer
           */
	function get_id()
	{
		return $this->id;
	}
        /**
         * set id
         * @package naanal
         * @param integer $id
         */
	function set_id($id)
	{
		$this->id=$id;
	}
	/**
         * get feature id
         * @package naanal
         * @return string
         */
  	public function get_feature_id()
  	{
  		return $this->feature_id;
  	}
        /**
         * set feature id
         * @package naanal
         * @param integer $feature_id
         */
  	public function set_feature_id($feature_id)
  	{
  		$this->feature_id=$feature_id;
  	}
        /**
         * get feature lookup
         * @package naanal
         * @return string
         */
  	public function get_feature_lookup()
  	{
		$this->pdo->setQuery("select * from feature");
  		$arrObj=$this->pdo->getAllObject("ClsWFeature");
  		$select='<select name="feature_id">
		<option value="">- Select -</option>';
		if($arrObj)
		foreach($arrObj as $ind=>$obj)
		{
			$selected="";
			if($obj->get_id()==$this->get_feature_id()) $selected=" selected";
			$select=$select.'<option value="'.$obj->get_id().'"'.$selected.'>'.$obj->get_name().'</option>';	
		}  		
		$select=$select.'</select>';
		return $select;
	}
	/**
         * get feature
         * @package naanal
         * @return string
         */  
	public function get_feature()
  	{
  		$this->pdo->setQuery("select * from feature where id=".$this->feature_id);
  		$obj = $this->pdo->getObject("ClsWFeature");
  		return $obj;
	}
  	/**
         * get permission
         * @package naanal
         * @return string
         */
  	public function get_permission()
  	{
  		return $this->permission;
  	}
        /**
         * set permission
         * @package naanal
         * @param string $permission
         */
  	public function set_permission($permission)
  	{
  		$this->permission=$permission;
  	}
        /**
         * getarray
         * @package naanal
         * @return array
         */
	function getArray()
	{
            $arr=null;
            $arr["id"]=$this->get_id();
            $arr["feature_id"]=$this->get_feature_id();
            $arr["permission"]=$this->get_permission();
            return $arr;
	}
        /**
         * setArray
         * @param array $arr
         * @return array
         */
	function setArray($arr)
	{
            if(isset($arr["id"])) $this->set_id($arr["id"]);
            if(isset($arr["feature_id"])) $this->set_feature_id($arr["feature_id"]);
            if(isset($arr["permission"])) $this->set_permission($arr["permission"]);
            return $arr;		
	}
 
}	
?>